package com.xyy.saas.payment.adpater.fumin.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;

/**
 * 版权所有：重庆富民银行股份有限公司
 * ---
 *
 * @author YJ
 * @version : v1.0
 * @date :2019/6/26
 **/
public class BaseUtils {

    public static String encryptToBase64(String filePath) {
        if (filePath == null) {
            return null;
        }
        try {
            byte[] b = Files.readAllBytes(Paths.get(filePath));
            return Base64.getEncoder().encodeToString(b);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;

    }

    public static void main(String[] args) throws IOException {
        String s = encryptToBase64("E:\\Fbank\\2019\\Sprint1925\\testfile.zip");
        File one =new File("E:\\Fbank\\2019\\Sprint1925\\testfilebase1.txt");
        FileWriter fileWriter = new FileWriter(one);
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
        bufferedWriter.write(s);
        bufferedWriter.close();

    }
}
